#pragma once

namespace Vortex { namespace Wrapper {

	///<summary>Wrapper COM call result</summary>
	public value class HResult : public System::IEquatable<HResult> {
		HRESULT _hResult;
	
	public:

		HResult(HRESULT hResult) : _hResult(hResult) {
		}

		///<summary>True if result is success</summary>
		property bool IsSuccess {
			bool get() { return _hResult == S_OK; }
		}

		///<summary>True if result is false</summary>
		property bool IsFalse {
			bool get() { return _hResult == S_FALSE; }
		}

		///<summary>True if result contains failure code</summary>
		property bool IsFailed {
			bool get() { return !!(_hResult & 0x80000000); }
		}

		///<summary>Value of result code</summary>
		property HRESULT Value {
			HRESULT get() { return _hResult; }
		}

		///<summary>Compares two HResult values</summary>
		virtual bool Equals(HResult other) {
			return _hResult == other._hResult;
		}

		static bool operator == (HResult left, HResult right) {
			return left._hResult == right._hResult;
		}

		static bool operator != (HResult left, HResult right) {
			return left._hResult != right._hResult;
		}

		static initonly HResult D3DError_InvalidCall = HResult(D3DERR_INVALIDCALL);
		static initonly HResult D3DError_InvalidDevice = HResult(D3DERR_INVALIDDEVICE);
		static initonly HResult D3DError_WrongTextureFormat = HResult(D3DERR_WRONGTEXTUREFORMAT);
		static initonly HResult D3DError_UnsupportedColorOperation = HResult(D3DERR_UNSUPPORTEDCOLOROPERATION);
		static initonly HResult D3DError_UnsupportedColorArg = HResult(D3DERR_UNSUPPORTEDCOLORARG);
		static initonly HResult D3DError_UnsupportedAlphaOperation = HResult(D3DERR_UNSUPPORTEDALPHAOPERATION);
		static initonly HResult D3DError_UnsupportedAlphaArg = HResult(D3DERR_UNSUPPORTEDALPHAARG);
		static initonly HResult D3DError_TooManyOperations = HResult(D3DERR_TOOMANYOPERATIONS);
		static initonly HResult D3DError_ConflictingTextureFilter = HResult(D3DERR_CONFLICTINGTEXTUREFILTER);
		static initonly HResult D3DError_UnsupportedFactorValue = HResult(D3DERR_UNSUPPORTEDFACTORVALUE);
		static initonly HResult D3DError_ConflictingRenderState = HResult(D3DERR_CONFLICTINGRENDERSTATE);
		static initonly HResult D3DError_UnsupportedTextureFilter = HResult(D3DERR_UNSUPPORTEDTEXTUREFILTER);
		static initonly HResult D3DError_ConflictingTexturePalette = HResult(D3DERR_CONFLICTINGTEXTUREPALETTE);
		static initonly HResult D3DError_DriverInternalError = HResult(D3DERR_DRIVERINTERNALERROR);

		static initonly HResult D3DError_NotFound = HResult(D3DERR_NOTFOUND);
		static initonly HResult D3DError_MoreData = HResult(D3DERR_MOREDATA);
		static initonly HResult D3DError_DeviceLost = HResult(D3DERR_DEVICELOST);
		static initonly HResult D3DError_DeviceNotReset = HResult(D3DERR_DEVICENOTRESET);
		static initonly HResult D3DError_NotAvailable = HResult(D3DERR_NOTAVAILABLE);
		static initonly HResult D3DError_OutOfVideoMemory = HResult(D3DERR_OUTOFVIDEOMEMORY);
		static initonly HResult D3DError_DriverInvalidCall = HResult(D3DERR_DRIVERINVALIDCALL);
		static initonly HResult D3DError_WasStillDrawing = HResult(D3DERR_WASSTILLDRAWING);
		static initonly HResult D3DOk_NoAutoGen = HResult(D3DOK_NOAUTOGEN);


	};

} }
